<template>
  <div class="info-box">
    <Cell is-link @click="showUser" class="cell-box cell-box1">
      <div class="my-box">
        <img src="../../assets/image/avatar-default.png" alt />
      </div>

      <template slot="title">
        <span class="custom-text">{{ this.userInfo.userName }}</span>
        <br />
        <span class="custom-text">{{ this.userInfo.phone }}</span>
      </template>
    </Cell>

    <Cell is-link v-for="(item, index) in myList" class="cell-box cell-box2" :key="index">
      <router-link :to="item.path" class="menu-items">
        <div class="img-box">
          <img :src="item.icon" alt />
        </div>
        <div>{{ item.menuName }}</div>
      </router-link>
    </Cell>
    <button class="buttoncl" @click="signOut">退出登录</button>
  </div>
</template>

<script>
import { getUserName, logout } from "@/api/Login";
import { getUserDetails } from "@/api/User";
import { Cell } from "vant";
export default {
  components: {
    Cell,
  },
  data() {
    return {
      myList: [
        {
          icon: require("../../assets/image/userCenter-cell1.png"),
          menuName: "企业信息",
          path: "/companymessage",
        },
        {
          icon: require("../../assets/image/userCenter-cell2.png"),
          menuName: "账号安全",
          path: "/accountSecurity",
        },
        {
          icon: require("../../assets/image/userCenter-cell3.png"),
          menuName: "意见反馈",
          path: "/fk",
        },
        // {
        //   icon: require("../../assets/image/userCenter-cell4.png"),
        //   menuName: "版权信息",
        //   path: "/copyrightInfo",
        // },
      ],
      userInfo: {},
    };
  },
  mounted() {
    this.getUserInfo();
  },
  methods: {
    // 获取用户信息
    getUserInfo() {
      if (localStorage.userInfo) {
        this.userInfo = JSON.parse(localStorage.userInfo);
      }
    },
    showUser() {
      this.$router.push({
        path: "/mymessage",
      });
    },
    // 退出登录
    signOut() {
      logout({ uid: this.userInfo.id }).then((res) => {
        localStorage.removeItem("token");
        localStorage.removeItem("isLogin");
        localStorage.removeItem("openId");
        localStorage.removeItem("userInfo");
        window.location.href = 'https://www.risesin.com/h5'
      });
    },
  },
};
</script>

<style lang="stylus" scoped>
@import './../../assets/styl/mixin.styl'
.info-box
  height 100vh
  background #F5F5F5
.bottom-box
  position fixed
  bottom 0
  z-index 2
  background $infoColor
.cell-box
  display flex
  justify-content space-between
  align-items center
  .menu-items
    display flex
    justify-content flex-start
    align-items center
    color #333
    .img-box
      width rem(16)
      height rem(16)
      display inline-block
      margin-right rem(8)
      img
        height 100%
        width 100%
        display block
  .my-box
    width rem(67.83)
    height rem(67.83)
    margin-left 50%
    text-align right
    img
      height 100%
      width 100%
.cell-box1
  .van-cell__right-icon
    height rem(67.83)
    line-height rem(67.83)
.cell-box2
  height rem(48)
  line-height rem(28)
.buttoncl
  margin-top rem(15)
  color #FF4D4F
  font-size rem($ft16)
  text-align center
  width 100%
  height rem(48)
  background #FFFFFF
</style>
<style lang="stylus" scoped>
@import './../../assets/styl/mixin.styl'
.van-cell::after
  right 0 !important
</style>